package utils;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 异常工具
 * @author zhangzc
 * @since 5/21/18
 */
public class ExceptionUtil {

    /**
     * 将异常堆栈转换成文本
     * @param e
     * @return
     */
    public static String getErrorInfoFromException(Throwable e) {
        if (e == null) {
            return "";
        } else {
            StringWriter sw = null;
            PrintWriter pw = null;

            String var4;
            try {
                sw = new StringWriter();
                pw = new PrintWriter(sw);
                e.printStackTrace(pw);
                String var3 = sw.toString();
                return var3;
            } catch (Exception var14) {
                var4 = "ErrorInfoFromException";
            } finally {
                try {
                    sw.close();
                    pw.close();
                } catch (IOException var13) {

                }

            }

            return var4;
        }
    }
}
